package alg20241016;

public class Text {

    public static void main(String[] args) {

    }
    public int maxArea1(int[] height) {
        int left = 0;
        int right = height.length-1;
        int[] Area = new int[height.length];
        int count = 0;
        while(left < right){
            if(height[left] < height[right]){
                Area[count++] = height[left] * (right - left);
                left++;
            }else{
                Area[count++] = height[right] * (right - left);
                right--;
            }
        }
           int max = Area[0];
        for (int i = 1; i <= count; i++) {
            if(Area[i] > max){
                max = Area[i];
            }
        }
        return max;
    }

    public int maxArea(int[] height) {
        int left = 0;
        int right = height.length-1;
        int ret = 0;
        while(left < right){
            int v = Math.min(height[left],height[right]) * (right - left);
            ret = Math.max(v, ret);
            if(height[left] < height[right]){
                left++;
            }else{
                right--;
            }
        }
        return ret;
    }
}
